home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Games / Doom / ADoom-0.8 / ADoom_src / r_defs.h < prev    next >
C/C++ Source or Header  |  1998-06-24  |  9KB  |  491 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION:
  18. //      Refresh/rendering module, shared data struct definitions.
  19. //
  20. //-----------------------------------------------------------------------------
  21.  
  22.  
  23. #ifndef __R_DEFS__
  24. #define __R_DEFS__
  25.  
  26.  
  27. // Screenwidth.
  28. #include "doomdef.h"
  29.  
  30. // Some more or less basic data types
  31. // we depend on.
  32. #include "m_fixed.h"
  33.  
  34. // We rely on the thinker data struct
  35. // to handle sound origins in sectors.
  36. #include "d_think.h"
  37. // SECTORS do store MObjs anyway.
  38. #include "p_mobj.h"
  39.  
  40.  
  41.  
  42. #ifdef __GNUG__
  43. #pragma interface
  44. #endif
  45.  
  46.  
  47.  
  48. // Silhouette, needed for clipping Segs (mainly)
  49. // and sprites representing things.
  50. #define SIL_NONE        0
  51. #define SIL_BOTTOM        1
  52. #define SIL_TOP            2
  53. #define SIL_BOTH        3
  54.  
  55. #define MAXDRAWSEGS        256
  56.  
  57.  
  58.  
  59.  
  60.  
  61. //
  62. // INTERNAL MAP TYPES
  63. //  used by play and refresh
  64. //
  65.  
  66. //
  67. // Your plain vanilla vertex.
  68. // Note: transformed values not buffered locally,
  69. //  like some DOOM-alikes ("wt", "WebView") did.
  70. //
  71. typedef struct
  72. {
  73.     fixed_t    x;
  74.     fixed_t    y;
  75.     
  76. } vertex_t;
  77.  
  78.  
  79. // Forward of LineDefs, for Sectors.
  80. struct line_s;
  81.  
  82. // Each sector has a degenmobj_t in its center
  83. //  for sound origin purposes.
  84. // I suppose this does not handle sound from
  85. //  moving objects (doppler), because
  86. //  position is prolly just buffered, not
  87. //  updated.
  88. typedef struct
  89. {
  90.     thinker_t        thinker;    // not used for anything
  91.     fixed_t        x;
  92.     fixed_t        y;
  93.     fixed_t        z;
  94.  
  95. } degenmobj_t;
  96.  
  97. //
  98. // The SECTORS record, at runtime.
  99. // Stores things/mobjs.
  100. //
  101. typedef    struct
  102. {
  103.     fixed_t    floorheight;
  104.     fixed_t    ceilingheight;
  105.     short    floorpic;
  106.     short    ceilingpic;
  107.     short    lightlevel;
  108.     short    special;
  109.     short    tag;
  110.  
  111.     // 0 = untraversed, 1,2 = sndlines -1
  112.     int        soundtraversed;
  113.  
  114.     // thing that made a sound (or null)
  115.     mobj_t*    soundtarget;
  116.  
  117.     // mapblock bounding box for height changes
  118.     int        blockbox[4];
  119.  
  120.     // origin for any sounds played by the sector
  121.     degenmobj_t    soundorg;
  122.  
  123.     // if == validcount, already checked
  124.     int        validcount;
  125.  
  126.     // list of mobjs in sector
  127.     mobj_t*    thinglist;
  128.  
  129.     // thinker_t for reversable actions
  130.     void*    specialdata;
  131.  
  132.     int            linecount;
  133.     struct line_s**    lines;    // [linecount] size
  134.     
  135. } sector_t;
  136.  
  137.  
  138.  
  139.  
  140. //
  141. // The SideDef.
  142. //
  143.  
  144. typedef struct
  145. {
  146.     // add this to the calculated texture column
  147.     fixed_t    textureoffset;
  148.     
  149.     // add this to the calculated texture top
  150.     fixed_t    rowoffset;
  151.  
  152.     // Texture indices.
  153.     // We do not maintain names here. 
  154.     short    toptexture;
  155.     short    bottomtexture;
  156.     short    midtexture;
  157.  
  158.     // Sector the SideDef is facing.
  159.     sector_t*    sector;
  160.     
  161. } side_t;
  162.  
  163.  
  164.  
  165. //
  166. // Move clipping aid for LineDefs.
  167. //
  168. typedef enum
  169. {
  170.     ST_HORIZONTAL,
  171.     ST_VERTICAL,
  172.     ST_POSITIVE,
  173.     ST_NEGATIVE
  174.  
  175. } slopetype_t;
  176.  
  177.  
  178.  
  179. typedef struct line_s
  180. {
  181.     // Vertices, from v1 to v2.
  182.     vertex_t*    v1;
  183.     vertex_t*    v2;
  184.  
  185.     // Precalculated v2 - v1 for side checking.
  186.     fixed_t    dx;
  187.     fixed_t    dy;
  188.  
  189.     // Animation related.
  190.     short    flags;
  191.     short    special;
  192.     short    tag;
  193.  
  194.     // Visual appearance: SideDefs.
  195.     //  sidenum[1] will be -1 if one sided
  196.     short    sidenum[2];            
  197.  
  198.     // Neat. Another bounding box, for the extent
  199.     //  of the LineDef.
  200.     fixed_t    bbox[4];
  201.  
  202.     // To aid move clipping.
  203.     slopetype_t    slopetype;
  204.  
  205.     // Front and back sector.
  206.     // Note: redundant? Can be retrieved from SideDefs.
  207.     sector_t*    frontsector;
  208.     sector_t*    backsector;
  209.  
  210.     // if == validcount, already checked
  211.     int        validcount;
  212.  
  213.     // thinker_t for reversable actions
  214.     void*    specialdata;        
  215. } line_t;
  216.  
  217.  
  218.  
  219.  
  220. //
  221. // A SubSector.
  222. // References a Sector.
  223. // Basically, this is a list of LineSegs,
  224. //  indicating the visible walls that define
  225. //  (all or some) sides of a convex BSP leaf.
  226. //
  227. typedef struct subsector_s
  228. {
  229.     sector_t*    sector;
  230.     short    numlines;
  231.     short    firstline;
  232.     
  233. } subsector_t;
  234.  
  235.  
  236.  
  237. //
  238. // The LineSeg.
  239. //
  240. typedef struct
  241. {
  242.     vertex_t*    v1;
  243.     vertex_t*    v2;
  244.     
  245.     fixed_t    offset;
  246.  
  247.     angle_t    angle;
  248.  
  249.     side_t*    sidedef;
  250.     line_t*    linedef;
  251.  
  252.     // Sector references.
  253.     // Could be retrieved from linedef, too.
  254.     // backsector is NULL for one sided lines
  255.     sector_t*    frontsector;
  256.     sector_t*    backsector;
  257.     
  258. } seg_t;
  259.  
  260.  
  261.  
  262. //
  263. // BSP node.
  264. //
  265. typedef struct
  266. {
  267.     // Partition line.
  268.     fixed_t    x;
  269.     fixed_t    y;
  270.     fixed_t    dx;
  271.     fixed_t    dy;
  272.  
  273.     // Bounding box for each child.
  274.     fixed_t    bbox[2][4];
  275.  
  276.     // If NF_SUBSECTOR its a subsector.
  277.     unsigned short children[2];
  278.     
  279. } node_t;
  280.  
  281.  
  282.  
  283.  
  284. // posts are runs of non masked source pixels
  285. typedef struct
  286. {
  287.     byte        topdelta;    // -1 is the last post in a column
  288.     byte        length;     // length data bytes follows
  289. } post_t;
  290.  
  291. // column_t is a list of 0 or more post_t, (byte)-1 terminated
  292. typedef post_t    column_t;
  293.  
  294.  
  295.  
  296. // PC direct to screen pointers
  297. //B UNUSED - keep till detailshift in r_draw.c resolved
  298. //extern byte*    destview;
  299. //extern byte*    destscreen;
  300.  
  301.  
  302.  
  303.  
  304.  
  305. //
  306. // OTHER TYPES
  307. //
  308.  
  309. // This could be wider for >8 bit display.
  310. // Indeed, true color support is posibble
  311. //  precalculating 24bpp lightmap/colormap LUT.
  312. //  from darkening PLAYPAL to all black.
  313. // Could even us emore than 32 levels.
  314. typedef byte    lighttable_t;    
  315.  
  316.  
  317.  
  318.  
  319. //
  320. // ?
  321. //
  322. typedef struct drawseg_s
  323. {
  324.     seg_t*        curline;
  325.     int            x1;
  326.     int            x2;
  327.  
  328.     fixed_t        scale1;
  329.     fixed_t        scale2;
  330.     fixed_t        scalestep;
  331.  
  332.     // 0=none, 1=bottom, 2=top, 3=both
  333.     int            silhouette;
  334.  
  335.     // do not clip sprites above this
  336.     fixed_t        bsilheight;
  337.  
  338.     // do not clip sprites below this
  339.     fixed_t        tsilheight;
  340.     
  341.     // Pointers to lists for sprite clipping,
  342.     //  all three adjusted so [x1] is first value.
  343.     short*        sprtopclip;        
  344.     short*        sprbottomclip;    
  345.     short*        maskedtexturecol;
  346.     
  347. } drawseg_t;
  348.  
  349.  
  350.  
  351. // Patches.
  352. // A patch holds one or more columns.
  353. // Patches are used for sprites and all masked pictures,
  354. // and we compose textures from the TEXTURE1/2 lists
  355. // of patches.
  356. typedef struct 
  357.     short        width;        // bounding box size 
  358.     short        height; 
  359.     short        leftoffset;    // pixels to the left of origin 
  360.     short        topoffset;    // pixels below the origin 
  361.     int            columnofs[8];    // only [width] used
  362.     // the [0] is &columnofs[width] 
  363. } patch_t;
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371. // A vissprite_t is a thing
  372. //  that will be drawn during a refresh.
  373. // I.e. a sprite object that is partly visible.
  374. typedef struct vissprite_s
  375. {
  376.     // Doubly linked list.
  377.     struct vissprite_s*    prev;
  378.     struct vissprite_s*    next;
  379.     
  380.     int            x1;
  381.     int            x2;
  382.  
  383.     // for line side calculation
  384.     fixed_t        gx;
  385.     fixed_t        gy;        
  386.  
  387.     // global bottom / top for silhouette clipping
  388.     fixed_t        gz;
  389.     fixed_t        gzt;
  390.  
  391.     // horizontal position of x1
  392.     fixed_t        startfrac;
  393.     
  394.     fixed_t        scale;
  395.     
  396.     // negative if flipped
  397.     fixed_t        xiscale;    
  398.  
  399.     fixed_t        texturemid;
  400.     int            patch;
  401.  
  402.     // for color translation and shadow draw,
  403.     //  maxbright frames as well
  404.     lighttable_t*    colormap;
  405.    
  406.     int            mobjflags;
  407.     
  408. } vissprite_t;
  409.  
  410.  
  411. //    
  412. // Sprites are patches with a special naming convention
  413. //  so they can be recognized by R_InitSprites.
  414. // The base name is NNNNFx or NNNNFxFx, with
  415. //  x indicating the rotation, x = 0, 1-7.
  416. // The sprite and frame specified by a thing_t
  417. //  is range checked at run time.
  418. // A sprite is a patch_t that is assumed to represent
  419. //  a three dimensional object and may have multiple
  420. //  rotations pre drawn.
  421. // Horizontal flipping is used to save space,
  422. //  thus NNNNF2F5 defines a mirrored patch.
  423. // Some sprites will only have one picture used
  424. // for all views: NNNNF0
  425. //
  426. typedef struct
  427. {
  428.     // If false use 0 for any position.
  429.     // Note: as eight entries are available,
  430.     //  we might as well insert the same name eight times.
  431.     boolean    rotate;
  432.  
  433.     // Lump to use for view angles 0-7.
  434.     short    lump[8];
  435.  
  436.     // Flip bit (1 = flip) to use for view angles 0-7.
  437.     byte    flip[8];
  438.     
  439. } spriteframe_t;
  440.  
  441.  
  442.  
  443. //
  444. // A sprite definition:
  445. //  a number of animation frames.
  446. //
  447. typedef struct
  448. {
  449.     int            numframes;
  450.     spriteframe_t*    spriteframes;
  451.  
  452. } spritedef_t;
  453.  
  454.  
  455.  
  456. //
  457. // Now what is a visplane, anyway?
  458. // 
  459. typedef struct
  460. {
  461.   fixed_t        height;
  462.   int            picnum;
  463.   int            lightlevel;
  464.   int            minx;
  465.   int            maxx;
  466.   
  467.   // leave pads for [minx-1]/[maxx+1]
  468.   
  469.   byte        pad1;
  470.   // Here lies the rub for all
  471.   //  dynamic resize/change of resolution.
  472.   byte        top[SCREENWIDTH];
  473.   byte        pad2;
  474.   byte        pad3;
  475.   // See above.
  476.   byte        bottom[SCREENWIDTH];
  477.   byte        pad4;
  478.  
  479. } visplane_t;
  480.  
  481.  
  482.  
  483.  
  484. #endif
  485. //-----------------------------------------------------------------------------
  486. //
  487. // $Log:$
  488. //
  489. //-----------------------------------------------------------------------------
  490.